# -*- coding: utf-8 -*-
'''
Created on Oct 13, 2012

@author: iflamed
'''
import top.api as topapi
import top
from Application import App
class TaobaokeItems(App):
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
        App.__init__(self)
        self.req=topapi.TaobaokeItemsGetRequest(self.url,self.port)
        self.req.set_app_info(top.appinfo(self.appkey,self.secret))
        
        
    def getItems(self,keyword):
        '''
        Get taobaoke items
        '''
        self.req.fields="num_iid,title,nick,pic_url,price,click_url,volume,shop_click_url";
        self.req.nick="liubing55750456";
        self.req.keyword=keyword;
        try:
            resp= self.req.getResponse();
            return resp;
        except Exception,e:
            return e;
        
    def getMenItems(self):
        '''
        Get taobaoke items
        '''
        self.req.fields="num_iid,title,nick,pic_url,price,click_url,volume,shop_click_url"
        self.req.nick="liubing55750456"
        self.req.keyword="男装"
        try:
            resp= self.req.getResponse()
            return resp
        except Exception,e:
            return e
class Categorys(App):
    def __init__(self):
        '''
        Constructor
        '''
        App.__init__(self)
        self.req=topapi.ItemcatsGetRequest(self.url,self.port)
        self.req.set_app_info(top.appinfo(self.appkey,self.secret))
    def getCatgorys(self,scid):
        self.req.fields="cid,parent_cid,name,is_parent"
        self.req.cids=scid
        try:
            resp= self.req.getResponse()
            return resp
        except Exception,e:
            print(e)
class ItemDetails(App):
    def __init__(self):
        '''
        Constructor
        '''
        App.__init__(self)
        self.req=topapi.TaobaokeItemsDetailGetRequest(self.url,self.port)
        self.req.set_app_info(top.appinfo(self.appkey,self.secret))
    def getItemDetails(self,itemid):
        self.req.fields="nick,cid,title,num,list_time,price,num_iid"
        self.req.num_iids=itemid
        try:
            resp= self.req.getResponse()
            return resp
        except Exception,e:
            print(e)
            
class ItemRelates(App):
    def __init__(self):
        '''
        Constructor
        '''
        App.__init__(self)
        self.req=topapi.TaobaokeItemsRelateGetRequest(self.url,self.port)
        self.req.set_app_info(top.appinfo(self.appkey,self.secret))
    def getItemRelates(self,itemid):
        self.req.fields="num_iid,title,price,pic_url,click_url,nick,volume,shop_click_url"
        self.req.relate_type=1
        self.req.max_count=16
        self.req.num_iid=itemid
        try:
            resp= self.req.getResponse()
            return resp
        except Exception,e:
            print(e)